<?php

header("Content-type:text/html;charset=utf-8");

$num = 0;
$dirname = 'practise';

$dirname = iconv( 'utf-8', 'gb2312',$dirname );

$dir_handle = opendir($dirname);

echo '<table border="0" align="center" width="600" cellspacing="0" cellpadding="0">';
echo '<caption><h2>目录'.$dirname.'下面的内容</h2></caption>';
echo '<tr align="left" background="#ccc">';
echo '<th>文件名</th><th>文件大小</th><th>文件类型</th><th>修改时间</th></tr>';

while($file = readdir($dir_handle)){

    $file1=iconv('gb2312','utf-8',$file);

    $dirFile = $dirname."/".$file;

    $bgcolor = $num++%2==0?'#fff':'#ccc';
    echo '<tr bgcolor='.$bgcolor.'>';
    echo '<td>'.$file1.'</td>';
    echo '<td>'.filesize($dirFile).'</td>';
    echo '<td>'.filetype($dirFile).'</td>';
    echo '<td>'.date("Y-n-t",filemtime($dirFile)).'</td>';
    echo '</tr>';
}

echo '</table>';
closedir($dir_handle);

echo '在<b>'.$dirname.'</b>目录下的子目录和文件共有<b>'.$num.'</b>个';